﻿Imports System.Data.OleDb
Public Class submitNews
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        Dim SqlString As String = "Insert into NewsItems(Title,Story,Submitted,SubmissionDate,Category) Values (@f1,@f2,@f3,@f4,@f5)"
        Dim newscmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        Dim dateString As String
        dateString = Date.Now.ToString("dd/MM/yyyy")
        newscmd.CommandType = CommandType.Text
        newscmd.Parameters.AddWithValue("@f1", TextBox1.Text)
        newscmd.Parameters.AddWithValue("@f2", TextBox2.Text)
        newscmd.Parameters.AddWithValue("@f3", User.Identity.Name)
        newscmd.Parameters.AddWithValue("@f4", dateString)
        newscmd.Parameters.AddWithValue("@f5", posttype.Value)
        
        oleDbConn.Open()
        newscmd.ExecuteNonQuery()
        Response.Redirect("newsConfirmation.aspx")
    End Sub
End Class